function [ys,params,check] = model_steadystate(ys,exo,M_,options_)

% read out parameters to access them with their name
NumberOfParameters = M_.param_nbr;
for ii = 1:NumberOfParameters
  paramname = M_.param_names{ii};
  eval([ paramname ' = M_.params(' int2str(ii) ');']);
end
% initialize indicator
check = 0;

%--------------------------------------------------------------------------
hU = hU_SS;  % hours worked
LU = LU_SS;  % leverage
PU = PU_SS;  % crisis probability
aU = 0;      % TFP shock

RbU = 1/beta_p;
ee = 1;
while ee > 1e-10
    RbUp = find_RbU(RbU,LU,PU,nu_p,alpha_p,siga_p,lam_p,delta_p,beta_p);
    ee = abs(RbU-RbUp);
    RbU = RbUp;
end
[~,gam_p,rkhatsU,rkhatU] = find_RbU(RbU,LU,PU,nu_p,alpha_p,siga_p,lam_p,delta_p,beta_p);

RkU = exp(rkhatU)+1-delta_p;
kU = (alpha_p/(RkU-1+delta_p))^(1/(1-alpha_p));
yU = kU^(alpha_p);
iU = delta_p*kU;
cU = yU - iU;
psi_p = (1-alpha_p)*yU;
nU = kU/LU;
n0_p = (1-chi1_p*(chi0_p*((alpha_p*yU/kU+1-delta_p)*LU-RbU*(LU-1)-1)+1)).*nU;
xiU = exp(rkhatU)/exp(rkhatsU);

% Read SS values
%--------------------------------------------------------------------------
% DO NOT CHANGE THIS PART.
% Here we define the steady state values of the endogenous variables of the model.
%

params=NaN(NumberOfParameters,1);
for iter = 1:length(M_.params) %update parameters set in the file
  eval([ 'params(' num2str(iter) ') = ' M_.param_names{iter} ';' ])
end

NumberOfEndogenousVariables = M_.orig_endo_nbr; %auxiliary variables are set automatically
for ii = 1:NumberOfEndogenousVariables
  varname = M_.endo_names{ii};
  eval(['ys(' int2str(ii) ') = ' varname ';']);
end
